﻿<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Base.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	TransceiverReport
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<ext:Viewport ID="ViewPort1" runat="server" Layout="fit">
        <Items>
            <ext:GridPanel ID="GridPanel1" runat="server" AutoExpandColumn="TransceiverTo" Header="false"
                Border="false" TrackMouseOver="true" StripeRows="true">
                <Store>
                    <ext:Store ID="dcCheck" runat="server" UseIdConfirmation="true">
                        <Proxy>
                            <ext:HttpProxy Url="/Transceiver/GetTransceiverReportStore/" />
                        </Proxy>
                        <BaseParams>
                            <ext:Parameter Name="range" Value="_range" Mode="Raw" />
                        </BaseParams>
                        <Reader>
                            <ext:JsonReader IDProperty="id" Root="data" TotalProperty="total">
                                <Fields>
                                    <ext:RecordField Name="TransceiverTo" />
                                    <ext:RecordField Name="TransceiverCount" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                        <SortInfo Field="TransceiverTo" Direction="DESC" />
                        <Listeners>
                            <Load Handler="updateTotal(#{GridPanel1});" />
                        </Listeners>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:RowNumbererColumn Width="25" Resizable="false" />
                        <ext:GroupingSummaryColumn Header="发送到" DataIndex="TransceiverTo" Width="130" SummaryType="Count" />
                        <ext:GroupingSummaryColumn Header="数量" DataIndex="TransceiverCount" Width="130" SummaryType="Sum" />
                    </Columns>
                    <Listeners>
                        <WidthChange Handler="updateTotal(#{GridPanel1});" />
                    </Listeners>
                </ColumnModel>
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server">
                        <Items>
                            <ext:SelectBox ID="sltRange" runat="server" DisplayField="text" ValueField="value">
                                <Store>
                                    <ext:Store runat="server" ID="dcRange">
                                        <Proxy>
                                            <ext:HttpProxy runat="server" Url="/Setting/ReportRange.xml" />
                                        </Proxy>
                                        <Reader>
                                            <ext:XmlReader Record="item">
                                                <Fields>
                                                    <ext:RecordField Name="value" Mapping="@value" />
                                                    <ext:RecordField Name="text" Mapping="@text" />
                                                </Fields>
                                            </ext:XmlReader>
                                        </Reader>
                                        <Listeners>
                                            <Load Handler="sltRange.selectFirst();" />
                                        </Listeners>
                                    </ext:Store>
                                </Store>
                                <Listeners>
                                    <Select Fn="rangeSelected" />
                                </Listeners>
                            </ext:SelectBox>
                            <%--<ext:Button ID="btnWorkloadTrendsChar" runat="server" Text="工作量走势" Icon="ChartCurve">
                                <Listeners>
                                    <Click Handler="showWorkloadTrendsChar();" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="btnWorkloadProportionChar" runat="server" Text="工作量比例" Icon="ChartPie">
                                <Listeners>
                                    <Click Handler="showWorkloadProportionChar();" />
                                </Listeners>
                            </ext:Button>
                            <ext:ToolbarFill ID="ToolbarFill1" runat="server" />--%>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Plugins>
                    <ext:GroupingSummary ID="GroupingSummary1" runat="server" />
                </Plugins>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                </SelectionModel>
                <Listeners>
                    <%--<Command Fn="commandHandler" />--%>
                    <ColumnResize Handler="updateTotal(#{GridPanel1});" />
                </Listeners>
                <LoadMask ShowMask="true" />
                <SaveMask ShowMask="true" />
                <BottomBar>
                    <ext:Toolbar ID="Toolbar2" runat="server">
                        <Items>
                            <ext:DisplayField ID="DisplayField1" runat="server" Width="25" />
                            <ext:DisplayField ID="ColumnField1" runat="server" DataIndex="TransceiverTo" Cls="total-field"
                                Text="-" />
                            <ext:DisplayField ID="ColumnField2" runat="server" DataIndex="TransceiverCount" Cls="total-field"
                                Text="-" />
                        </Items>
                    </ext:Toolbar>
                </BottomBar>
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeaderArea" runat="server">
    <script type="text/javascript" language="javascript">
        var _range = 1;

        var rangeSelected = function (item, record, index) {
//            chart.destroy();
//            DrawChart();
        }
    </script>
    <style type="text/css">
        .x-grid3-cell-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid-group-hd div
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
        }
        
        .x-grid3-hd-inner
        {
            font-family: "segoe ui" ,tahoma, arial, sans-serif;
            font-size: 12px;
        }
        
        .x-grid3-body .x-grid3-td-Cost
        {
            background-color: #f1f2f4;
        }
        
        .x-grid3-summary-row .x-grid3-td-Cost
        {
            background-color: #e1e2e4;
        }
        
        .total-field
        {
            background-color: #fff;
            font-weight: bold !important;
            color: #000;
            border: solid 1px silver;
            padding: 2px;
            margin-right: 5px;
        }
    </style>
    <script type="text/javascript">
        var updateTotal = function (grid) {
            var fbar = grid.getBottomToolbar(),
                column,
                field,
                width,
                data = {},
                c,
                cs = grid.view.getColumnData();

            for (var j = 0, jlen = grid.store.getCount(); j < jlen; j++) {
                var r = grid.store.getAt(j);

                for (var i = 0, len = cs.length; i < len; i++) {
                    c = cs[i];
                    column = grid.getColumnModel().columns[i];

                    if (column.summaryType) {
                        data[c.name] = Ext.grid.GroupSummary.Calculations[column.summaryType](data[c.name] || 0, r, c.name, data);
                    }
                }
            }

            for (var i = 0; i < grid.getColumnModel().columns.length; i++) {
                column = grid.getColumnModel().columns[i];

                if (column.dataIndex != grid.store.groupField) {
                    field = fbar.findBy(function (item) {
                        return item.dataIndex === column.dataIndex;
                    })[0];

                    if (typeof (field) != 'undefined') {
                        c = cs[i];
                        fbar.remove(field, false);
                        fbar.insert(i, field);
                        width = grid.getColumnModel().getColumnWidth(i);
                        field.setWidth(width - 5);
                        field.setValue((column.summaryRenderer || c.renderer)(data[c.name], {}, {}, 0, i, grid.store));
                    }
                }
            }

            fbar.doLayout();
        }
    </script>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="StartupArea" runat="server">
</asp:Content>
